limsBatch.auditPage = {

    getGridParam: function () {
        var _this = this;
        return {
            type: 'grid',
            id: 'lims-batch-audit-list-grid',
            url: limsBatch.baseUrl + '/queries',
            requestData: {
                status_EQ: 'approve'
            },
            page: true,
            columns: limsBatch.getAuditListColumns(),
            onCellClick: function (field, row) {
                field === 'batchCode' && Gikam.loadBatchDetailPageV12(row.id, true);
            },
            toolbar: [{
                type: 'button',
                text: 'GIKAM.WORKFLOW.BUTTON.PASS',
                icon: 'pass',
                onClick: function () {
                    _this.pass();
                }
            }, {
                type: 'button',
                text: 'GIKAM.WORKFLOW.BUTTON.REJECT',
                icon: 'reject',
                onClick: function () {
                    _this.reject();
                }
            }],
        }
    },

    pass: function () {
        var grid = Gikam.getComp('lims-batch-audit-list-grid');
        let selections = grid.getSelections();
        Gikam.confirm('CORE.MODULE.ITEM.MESSAGES.TIP.CONFIRM', 'GIKAM.WORKFLOW.BUTTON.PASS', function () {
            Gikam.postText(limsBatch.baseUrl + '/approve', Gikam.getJsonWrapper(null, [null, selections])).done(function () {
                grid.refresh()
            })
        })
    },

    reject: function () {
        var grid = Gikam.getComp('lims-batch-audit-list-grid');
        let selections = grid.getSelections();
        Gikam.confirm('CORE.MODULE.ITEM.MESSAGES.TIP.CONFIRM', 'GIKAM.WORKFLOW.BUTTON.REJECT', function () {
            Gikam.postText(limsBatch.baseUrl + '/reject', Gikam.getJsonWrapper(null, [null, selections])).done(function () {
                grid.refresh()
            })
        })
    },


    create: function () {
        var _this = this;
        Gikam.create('layout', {
            id: 'lims-batch-edit-list-layout',
            renderTo: workspace.window.$dom,
            center: {
                items: [this.getGridParam()]
            }
        });
    },

    init: function () {
        this.create();
    }
};
